<?php
include $_SERVER['DOCUMENT_ROOT'] . '/lib/User.php';
$userOb = new User();
$lienhe = array(
    'id' => null,
    'yahoo' => null,
    'sodienthoai' => null,
    'diachi' => null,
    'tenchu'=>null
);
$lienhe = $userOb->layLienHe('1');
$message = array();
if (isset($_POST['capnhat'])) {
        if($userOb->capnhapLienHe('1', $_POST)){
            header('Location: /admin/lienhe.php');
        }else{
            $message[]="Cập nhật thất bại";
        }
}
?>
<form method="post" action="">
    <table style="margin: 10px auto" width="500px" border="1" align="center" cellspacing="1">
        <tr>
            <td bgcolor="#00CCFF" colspan="2"><p align="center"><b>Thông tin liên lạc</b></p></td>         
        </tr>
        <?php if (count($message) > 0): ?>
            <tr>
                <td colspan="2">
                    <?php foreach ($message as $mes): ?>
                        <p><?php echo $mes ?></p>
                    <?php endforeach; ?>
                </td>         
            </tr>
        <?php endif; ?>
        <tr>
            <td width="150px" align="right">Yahoo:</td>
            <td><input type="text" value="<?php echo $lienhe['yahoo'] ?>"  name="yahoo" id="yahoo" size="40px" /></td>
        </tr>
        <tr>
            <td width="150px" align="right">Địa chỉ:</td>
            <td><input type="text" value="<?php echo $lienhe['sodienthoai'] ?>"  name="sodienthoai" id="sodienthoai" size="40px" /></td>
        </tr>
        <tr>
            <td width="150px" align="right">Số điện thoại:</td>
            <td><input type="text" value="<?php echo $lienhe['diachi'] ?>"  name="diachi" id="diachi" size="40px" /></td>
        </tr>
        <tr>
            <td width="150px" align="right">Tên chủ cửa hàng:</td>
            <td><input type="text" value="<?php echo $lienhe['tenchu'] ?>"  name="tenchu" id="tenchu" size="40px" /></td>
        </tr>
        <tr>
            <td width="150px" align="right">Tên Shop:</td>
            <td><input type="text" value="<?php echo $lienhe['lienlac'] ?>"  name="lienlac" id="lienlac" size="40px" /></td>
        </tr>
        <tr>
            <td align="right"><input type="submit" name="capnhat" id="capnhat" value="Cập nhật"</td>
        </tr>
    </table>
</form>